﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Zor_DAL;
using Zor_Tools;

namespace Zor_Bll
{
    /// <summary>
    /// 租户（个人）信息
    /// create by Guoph at 2017.3.28
    /// </summary>
    public class TenantPersonHousBrowse_Bll<T> where T : class
    {
        /// <summary>
        /// 获取租户（个人）信息列表
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="TotalCount">返回值</param>
        /// <returns></returns>
        public static List<T> GetPageList(dynamic Model, int index, out int TotalCount,string where)
        {
            int Dtid = RequestSession.GetSessionUser().DT_Id;
            int Isadmin = RequestSession.GetSessionUser().Is_Admin;
            var sqlSurch = " 1=1 ";
            if (Isadmin == 1 || Dtid == 16)
            {
                sqlSurch = " 1=1 ";
            }
            else
            {
                sqlSurch = "( StreetOfficeID = " + Dtid + " or Dt_ParentId = " + Dtid + " )";
            }
            if (Model.StreetOffice != null)
            {
                sqlSurch += " and " + " StreetOffice like '%" + Model.StreetOffice + "%'  ";
            }
            if (Model.Community != null)
            {
                sqlSurch += " and " + " Community like '%" + Model.Community + "%'  ";
            }
            if (Model.Tenant_Name != null)
            {
                sqlSurch += " and " + " Tenant_Name like '%" + Model.Tenant_Name + "%'  ";
            }
            if (Model.Tenant_IDNumber != null)
            {
                sqlSurch += " and " + " Tenant_IDNumber = '" + Model.Tenant_IDNumber + "'  ";
            }
            if (Model.Tenant_Phone != null)
            {
                sqlSurch += " and " + " Tenant_Phone like '%" + Model.Tenant_Phone + "%'  ";
            }
            if (Model.Tenant_Company != null)
            {
                sqlSurch += " and " + " Tenant_Company like '%" + Model.Tenant_Company + "%'  ";
            }
            if (Model.Tenant_Vocation != null)
            {
                sqlSurch += " and " + " Tenant_Vocation like '%" + Model.Tenant_Vocation + "%'  ";
            }
            if (Model.Tenant_Nature != null)
            {
                sqlSurch += " and " + " Tenant_Nature like '%" + Model.Tenant_Nature + "%'  ";
            }
            if (Model.Tenant_Code != null)
            {
                sqlSurch += " and " + " Tenant_Code like '%" + Model.Tenant_Code + "%'  ";
            }
            return PagerHelp<T>.GetPagerList(index, "V_TenantPersonHousBrowse", "Community", out TotalCount, sqlSurch);
        }
    }
}
